/**
 * @copyright 2015 Indie Semiconductor.
 *
 * This file is proprietary to Indie Semiconductor.
 * All rights reserved. Reproduction or distribution, in whole
 * or in part, is forbidden except by express written permission
 * of Indie Semiconductor.
 *
 * @file hwcfg.h
 * Hardware configuration for Bon.
 */

#ifndef __HWCFG_H__
#define __HWCFG_H__

#include "pwm_device.h"

/**
 * @brief The system clock in Hz.
 */
#define E_HWCFG_SYSTEM_CLOCK          16000000
#define E_HWCFG_SYSTEM_CLOCK_LOW      10000

/**
 * @brief The system clock in KHz.
 */
#define E_HWCFG_SYSTEM_CLOCK_KHZ      (E_HWCFG_SYSTEM_CLOCK/1000)

    
#define E_HWCFG_ADC_RANGE_FULL       255
#define E_HWCFG_ADC_RANGE_ZERO       0
#define E_HWCFG_ADC_VBG              1200

#define E_HWCFG_ADC_REF_H_DFLT       0x0F
#define E_HWCFG_ADC_REF_L_DFLT       0x00
#define E_HWCFG_ADC_REF_G_DFLT       0x0F
#define E_HWCFG_ADC_GAIN_ONE         128
     



  



/**
 * @brief A structure to represent the data in hardware config block.
 */
typedef struct {
   uint8_t CHIP_ID[8];
   uint8_t CALIB_VERSION;
   uint8_t BANDGAP_VOLT;
   uint8_t CLOCK_CALIB_RC;
   uint8_t CLOCK_CALIB_32K; 
} HWCFG_SFRS_t;

/**
 * @brief The starting address of hardware config block.
 */
#define HWCFG_SFRS ((__IO HWCFG_SFRS_t *) (0x00027F00))


uint8_t HWCFG_GetRCHFClockCalibValue(void);
uint8_t HWCFG_GetRCLFClockCalibValue(void);

/**
 * @brief Get RC clock trim value.
 *
 * @return The trim value stored in flash memory.
 */
uint8_t HWCFG_GetRCClockCalibValue(void);

/**
 * @brief Get 32K clock trim value.
 *
 * @return The trim value stored in flash memory.
 */
uint8_t HWCFG_Get32KClockCalibValue(void);

/**
 * @brief Get band gap voltage.
 *
 * @return The trim value stored in flash memory.
 */
uint16_t HWCFG_GetVBG(void);

/**
 * @brief Get the version of calibration data.
 *
 * @return The version for this calibration data block.
 */
uint8_t HWCFG_GetCalibrationVersion(void);

int16_t HWCFG_GetV2ICalibrationValue(CurrValue_t value);
int16_t HWCFG_GetLEDCalibrationValue(PwmChannel_t channel, CurrValue_t value);

#endif /* __HWCFG_H__ */



